import { tableOption } from './structure.config.js'
import search from './../search/search.js';
import TrendChart from '@/components/Charts/TrendChart.vue';
import { mapGetters } from 'vuex'
export default {
    name: "structure",
    mixins: [search],
    components: {
        TrendChart
    },
    computed: {
        ...mapGetters(['permissions']),
        permissionList() {
            return {
                addBtn: this.vaildData(this.permissions.cms_categoty_add, false),
                delBtn: this.vaildData(this.permissions.cms_categoty_del, false),
                editBtn: this.vaildData(this.permissions.cms_categoty_edit, false)
            }
        }
    },
    data() {
        return {
            tableOption: tableOption,
            loading: false,
            loadData: [{
                id: 1,
            }],
            page: {
                currentPage: 1,
                total: 0,
                pageSize: 10
            },
            btn: [

                {
                    title: "导出数据",
                    isShow: true
                },
            ],
            dialogVisible: false,   //趋势图
            dataList: ['销量', '支付营收', '支付均价'],
            dataX: [],
            dataValue: [
                {
                    name: '销量',
                    type: 'line',
                    stack: '总量',
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: '支付营收',
                    type: 'line',
                    stack: '总量',
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: '支付均价',
                    type: 'line',
                    stack: '总量',
                    data: [150, 232, 201, 154, 190, 330, 410]
                },
            ]
        }
    },
    created(){
        // this.time()
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
            }
            if (page) {
                this.page.current = page
            }
            setTimeout(() => {
                this.page.total = 200
                this.$emit("trigger")
            }, 500)
        },
        sizeChange(currentPage) {
            this.page.currentPage = currentPage
        },
        currentChange(pageSize) {
            this.page.pageSize = pageSize
        },
        handler(index) {
            if (index == 0) {
                this.export()
            }
        },
        trend(item) {
            this.dialogVisible = true
        },
        export() {

        },
        time() {
            var myDate = new Date(); //获取今天日期
            myDate.setDate(myDate.getDate() - 6);
            var dateArray = [];
            var dateTemp;
            var flag = 1;
            for (var i = 0; i < 7; i++) {
                dateTemp = myDate.getMonth() + 1 + "-" + myDate.getDate();
                dateArray.push(dateTemp);
                myDate.setDate(myDate.getDate() + flag);
            }
            this.dataX = dateArray;
        }
    }

} 